package vcsn.ui.view.adapter;

import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;

import vcsn.Config;
import vcsn.entities.CommitPatch;

public class CommitPatchPropertySource implements IPropertySource {
	
	private final CommitPatch commitPatch;
	
	public CommitPatchPropertySource(CommitPatch commitPatch) {
	    this.commitPatch = commitPatch;
	  }
	
	@Override
	public Object getEditableValue() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public IPropertyDescriptor[] getPropertyDescriptors() {
		// TODO Auto-generated method stub
		return new IPropertyDescriptor[] {
		        new TextPropertyDescriptor(Config.propertyIDAuthor, "Author"),
		        new TextPropertyDescriptor(Config.propertyIDPatchHash, "Patch Hash"),
		        new TextPropertyDescriptor(Config.propertyIDPatchPath, "Patch Location"),
		        new TextPropertyDescriptor(Config.propertyIDRelationDiffPath, "Relation Diff Location"),
		        new TextPropertyDescriptor(Config.propertyIDBuildDate, "Build Date"),
		        new TextPropertyDescriptor(Config.propertyIDSenderAddr, "Sender Address"),
		        new TextPropertyDescriptor(Config.propertyIDEstimatedConflictCount, "Est. Conflict Count"),
		        new TextPropertyDescriptor(Config.propertyIDEstimatedRefactorCount, "Est. Refactor Count") };
	}

	@Override
	public Object getPropertyValue(Object id) {
		// TODO Auto-generated method stub
		if (id.equals(Config.propertyIDAuthor)) {
		      return commitPatch.getAuthor();
		    }
		    if(id.equals(Config.propertyIDPatchHash)){
		    	return commitPatch.getPatchHash();
		    }
		    if(id.equals(Config.propertyIDPatchPath)){
		    	return commitPatch.getPatchPath();
		    }
		    if(id.equals(Config.propertyIDRelationDiffPath)){
		    	return commitPatch.getRelationDiffPath();
		    }
		    if(id.equals(Config.propertyIDEstimatedConflictCount)){
		    	return commitPatch.getEstimatedConflict();
		    }
		    if (id.equals(Config.propertyIDBuildDate)) {
			      return commitPatch.getBuildDate();
			}
		    if (id.equals(Config.propertyIDSenderAddr)) {
			      return commitPatch.getSenderAddr();
			}
		    if (id.equals(Config.propertyIDEstimatedRefactorCount)) {
			      return commitPatch.getEstimatedRefactor();
			}
		    return null;
	}

	@Override
	public boolean isPropertySet(Object id) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void resetPropertyValue(Object id) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void setPropertyValue(Object id, Object value) {
	}
}
